/**
 * 确认提示框
 */
class ConfirmUI extends UIBase{
    public btn_close:BaseButton;
    public lb_tips:eui.Label;
    public btn_sure:BaseButton;
    public lb_tips1:eui.Label;
    private group_iconTips:eui.Group;
    private img_icon:eui.Image;
    private img_di_1:eui.Image;
    private lb_tips2:eui.Label;
    private lb_tittle:eui.Label;
    private scriptData;
    private btn_get:BaseButton;
    constructor(data)
    {
        super('ConfirmView', data)
    }

    public init()
    {
        super.init(true);
        this.scriptData = this.data.scriptData;
        if(this.scriptData.iconUrl)
        {
            this.group_iconTips.visible = true;
            this.lb_tips.visible = false;
            this.lb_tips1.text = this.scriptData.tips;
            this.img_icon.source = this.scriptData.iconUrl;
            
            this.img_di_1.visible = false;
            this.lb_tittle.text = '三箭齐发';
            this.btn_sure.visible = false;
            this.btn_get.visible = true;
            let video_cnt = GameManager.instance.todayVedioTimes;
            if(video_cnt >= GameConst.MaxVedioCnt)
            {
                let img_btn:eui.Image = this.btn_get.getChildByName('img_btn') as eui.Image;
                img_btn.source = 'btn_three_contineu_1_png';
                this.lb_tips2.text = 'x5';
            }
        }
        else
        {
            this.lb_tips.text = this.scriptData.tips;
        }
        
    }

    public addEvent()
    {
        this.btn_sure.addTapHandler(this.sureHandle, this);
        this.btn_close.addTapHandler(this.closeHandle, this);
        this.btn_get.addTapHandler(this.sureHandle, this);
    }

    protected sureHandle()
    {
        let sureCall:Function = this.scriptData.sureCall;
        if(sureCall)
        {
            let scope = this.scriptData.scope;
            sureCall.call(scope);
        }
        this.remove();
    }

    protected closeHandle()
    {
        let closeCall:Function = this.scriptData.closeCall;
        if(closeCall)
        {
            let scope = this.scriptData.scope;
            closeCall.call(scope);
        }
        this.remove();
    }

    public removeEvent()
    {
        this.btn_sure.removeTapHandler();
        this.btn_close.removeTapHandler();
        this.btn_get.removeTapHandler();
    }

    public clear()
    {
        super.clear();
        this.scriptData = null;
    }
}